<?php
include 'document_log_lib.php';

$a_css_files = array (
    array ( 'path' => 'plugins/jquery-ui/jquery-ui-1.10.1.custom.min.css' ),
);


$a_js_files = array (
    array ( 'path' => 'scripts/nh-document.js' ),
);

$a_js_class[] = 'NH_Document.init();';

$a_user = array ( );
$a_document_logs = array ( );
$s_Where = 'where 1=1 ';

// <editor-fold defaultstate="collapsed" desc="Make Where">
make_where($s_Where, $a_filterings);
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Get Data">
$db_query = "select count(id) from document_log $s_Where limit 1";
$d_total  = db_query_single_value($db_conn, $db_query);

namhoa_pagelink($s_Pagination, $s_ScriptName, $s_QueryString, $i_Page, $i_Page_Size, $s_Page_Start, $d_total);

$db_query  = db_get_query($a_tablecolumns_namhoa_document_log) . $s_Where . " order by id desc";
$db_result = db_query_page($db_conn, $db_query, $s_Page_Start, $i_Page_Size);

while ($d_row = db_fetch($db_result)) {
    $a_document_logs[$d_row->id] = $d_row;
    $a_user[$d_row->userid]      = $d_row->userid;
}

$a_user = get_user_info($a_user, $db_conn);
// </editor-fold>

include 'lib_head.php';
?>
<div class="row-fluid">
    <!-- BEGIN BORDERED TABLE PORTLET-->
    <div class="portlet box green">
        <div class="portlet-title">
            <div class="caption"><i class="icon-filter"></i>Lọc Dữ Liệu</div>
            <div class="tools">
                <a href="javascript:;" class="collapse"></a>
                <a href="#portlet-config" data-toggle="modal" class="config"></a>
            </div>
        </div>
        <div class="portlet-body">
            <form action="" style="margin: 0">                
                <div class="pull-left margin-right-20">
                    <div class="control-group">
                        <label class="control-label">Ngày</label>
                        <div class="controls">
                            <input type="text" name="category1" id="category1" value="<?= $s_category1 ? $s_category1 : '' ?>" class="m-wrap datepicker span12 text-center" placeholder="24-12-0000">
                        </div>
                    </div>
                </div>
                <div class="pull-left margin-right-20">
                    <div class="control-group">
                        <label class="control-label">Lọc Theo</label>
                        <div class="controls">
                            <div class="input-prepend">
                                <div class="btn-group">
                                    <select name="field1" class="m-wrap medium">
                                        <?php build_advanced_filter_namhoa_document_log($s_field1, $a_hide_filter); ?>
                                    </select>
                                </div>
                                <input class="m-wrap medium" name="keyword1" type="text" value="<?= check_plain($s_keyword1) ?>"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="pull-left">
                    <div class="control-group">
                        <label class="control-label">&ensp;</label>
                        <div class="controls">
                            <div class="input-prepend">
                                <button class="btn blue">BẮT ĐẦU LỌC <i class="m-icon-swapright m-icon-white"></i></button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="clearfix"></div>
            </form>
        </div>
    </div>
    <!-- END BORDERED TABLE PORTLET-->
    <div class="portlet-body">
        <table class="table table-striped table-hover">
            <thead>
                <tr>
                    <th class="hidden-phone">Log ID</th>
                    <th>Tên Thánh - Họ Và Tên</th>
                    <th>Tập Tin</th>
                    <th>Ghi Chú</th>
                    <th>Ngày Tạo</th>
                </tr>
            </thead>
            <?php foreach ($a_document_logs as $v_id => $a_Info) { ?>
                <tbody>
                    <tr>
                        <td class="text-center hidden-phone"><?= $a_Info->id ?></td>
                        <td>
                            <a href="user_detail.php?userid=<?= $a_Info->userid ?>">
                                <?= check_plain($a_user[$a_Info->userid]->saint . " " . $a_user[$a_Info->userid]->username) ?>
                            </a>
                        </td>
                        <td><?= $a_Info->filename ?></td>
                        <td><?= $a_Info->note ?></td>
                        <td><?= namhoa_date($a_Info->updatedate, true) ?></td>
                    </tr>
                </tbody>
            <?php } ?>
        </table>
    </div>
    <div class="pagination pagination-centered">
        <?= $s_Pagination ?>
    </div>
</div>
<?php include 'lib_tail.php'; ?>